package edu.siu.math.egut.egut;


/**
 * Wraps a string inside a LiE text object
 * 
 * @author Joe Pleso
 *
 */
public class LiEText extends AbstractLiEObject {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private final String result;
    private final String s;
    
    /**
     * Wraps a java string inside a LiE text object
     * 
     * @param s java string to be wrapped
     */
    public LiEText(String s) {
	super(LiEType.TEX);

	this.s = s;
	StringBuffer sb = new StringBuffer();
	sb.append(Algorithms.LIE_PRINT_COMMAND
		+ Algorithms.LIE_LEFT_PARENTHESIS
		+ Algorithms.LIE_QUOTE);
	for (int i = 0; i < s.length(); i++){
	    if (s.charAt(i) == Algorithms.LIE_NEWLINE){
		sb.append(Algorithms.LIE_QUOTE);
		sb.append(Algorithms.LIE_RIGHT_PARENTHESIS);
		sb.append(Algorithms.LIE_NEWLINE);
		sb.append(Algorithms.LIE_PRINT_COMMAND
			+ Algorithms.LIE_LEFT_PARENTHESIS
			+ Algorithms.LIE_QUOTE);
	    }else

	    sb.append(s.charAt(i));
	}
	sb.append(Algorithms.LIE_QUOTE);
	sb.append(Algorithms.LIE_RIGHT_PARENTHESIS);
	result = sb.toString();
    }

    public String toString(){
	return result;
    }
    
    
    public Object getJavaObject() {
	
	return s;
    }

}
